package com.ly.demo.weixin.interceptor;


import com.ly.demo.weixin.WeixinManager;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;

import javax.annotation.Resource;

@Slf4j
public class AccessTokenInterceptor implements RequestInterceptor {
    @Resource
    @Lazy
    private WeixinManager weixinManager;

    @Override
    public void apply(RequestTemplate template) {
        String accessToken = weixinManager.getAccessToken();
        template.query("access_token", accessToken);
    }
}
